﻿@using IterationLife.FootballTeaching.Queries
@using Util.Ui
@model IterationLife.PlatformBackEnd.AppServices.Dtos.FootballTeachings.ChapterDto
@{
    var x = @Html.EasyUi();
}

<script type="text/javascript">
    var grid_chapter_refresh = function () {
        $.easyui.refresh("formQuery_chapter", "grid_chapter");
    }

    var panel_chapter_refresh = function (id) {
        $.easyui.refreshPanel("panel_lesson", "/FootballTeachings/lesson/Grid?chapterId=" + id);
    }

    var panel_chapter_onGridClickRow = function (index, row) {
        panel_chapter_refresh(row.Id);
    }

    var panel_chapter_onLoadSuccess = function (data) {
        if (data.total === 0) {
            panel_chapter_refresh("");
            return;
        }
        panel_chapter_refresh(data.rows[0].Id);
    }
</script>

@using (x.Layout(true).Begin())
{
    using (x.LayoutRegion().Top().Height(65).Begin())
    {
        <div class="titlebar">
            <span class="title">当前课程：</span>
            <span>@Model.CourseName</span>
        </div>
        <div class="toolbar">
            @x.DialogButton("添加章节", $"/FootballTeachings/chapter/NewDto?courseId={Model.CourseId}").Icon("icon-add").Plain().OnClose("grid_chapter_refresh").DialogSize(400,200)
            @x.DialogButton("编辑章节", "/FootballTeachings/chapter/edit").Id("btnEdit_chapter").Icon("icon-edit").Plain().ShowEditDialog("grid_chapter").OnClose("grid_course_refresh").DialogSize(400, 200)
            @x.Button("删除章节").Icon("icon-delete").Plain().Delete("/FootballTeachings/chapter/delete", "", "grid_chapter")
            @x.DialogButton("查看详细", "/FootballTeachings/chapter/detail").Id("btnLook").Icon("icon-look").Plain().ShowDetailDialog("grid_chapter").DialogSize(500, 200)
            @x.Button("刷 新").Icon("icon-refresh").Plain().Refresh("formQuery_chapter", "grid_chapter")
        </div>
    }
    using (x.LayoutRegion().Center().Begin())
    {
        @Html.Partial("Parts/QueryForm", new ChapterQuery { CourseId = Model.CourseId })
        @(x.Grid("grid_chapter").Sort("SortId",false).Toolbar("divQuery_chapter").Url($"/FootballTeachings/Chapter/PagerQuery?CourseId={Model.CourseId}")
        .ShowEditDialogByDblClick("btnEdit_chapter").Menu().FitColumns().Fit()
        .Columns(
            x.GridColumn(t => t.Id).CheckBox(),
            x.GridColumn(t => t.SortId, 100),
            x.GridColumn(t => t.Name, 100),
            x.GridColumn(t => t.CreationTime, 120)
        ) .AddDataOption("onClickRow", "panel_chapter_onGridClickRow")
              .OnLoadSuccess("panel_chapter_onLoadSuccess")
              .Pagination(true,10)
        )
    }
    using (@x.Panel().Id("panel_lesson").Bottom().Split().Title("面料项管理").Height(500).AddClass("content").Begin())
    {
    }
}